<template>
  <div class="exam-type-selection">
    <h3>选择文章类型</h3>
    <div class="type-buttons">
      <button v-for="type in examTypes" :key="type.value"
        :class="['type-button', { active: selectedType === type.value }, type.status]" @click="selectType(type.value)"
        :disabled="type.status === 'coming'">
        <div class="type-icon">{{ type.icon }}</div>
        <div class="type-label">{{ type.label }}</div>
        <div class="type-desc">{{ type.description }}</div>
        <div class="status-badge" v-if="type.status === 'beta'">测试中</div>
        <div class="status-badge coming" v-if="type.status === 'coming'">即将上线</div>
      </button>
    </div>
  </div>
</template>

<script>
import { ref } from 'vue';

export default {
  name: 'ExamTypeSelector',
  props: {
    selectedType: {
      type: String,
      default: 'cet4_6'
    }
  },
  emits: ['typeChange'],
  setup(props, { emit }) {
    const examTypes = ref([
      {
        value: 'primary',
        label: '小学作文',
        description: '小学阶段作文评估',
        icon: '🎒',
        status: 'stable'
      },
      {
        value: 'middle_school',
        label: '中学作文',
        description: '初高中作文评估',
        icon: '📚',
        status: 'stable'
      },
      {
        value: 'cet4_6',
        label: 'CET4/6',
        description: '大学英语四六级',
        icon: '🎓',
        status: 'stable'
      },
      {
        value: 'ielts_toefl',
        label: 'IELTS/TOEFL',
        description: '雅思托福考试',
        icon: '🌍',
        status: 'stable'
      },
      {
        value: 'civil_exam',
        label: '公务员考试',
        description: '公务员申论写作',
        icon: '🏛️',
        status: 'stable'
      }
    ]);

    const selectType = (type) => {
      emit('typeChange', type);
    };

    const getTypeName = (value) => {
      const type = examTypes.value.find(t => t.value === value);
      return type ? type.label : '作文分析报告';
    };

    return {
      examTypes,
      selectType,
      getTypeName
    };
  }
};
</script>

<style scoped>
.exam-type-selection {
  margin-bottom: 30px;
  padding: 25px;
  background: #f8f9fa;
  border-radius: 12px;
  border: 1px solid rgba(58, 134, 255, 0.1);
}

.exam-type-selection h3 {
  margin-top: 0;
  margin-bottom: 20px;
  color: #333;
  font-size: 1.2rem;
  text-align: center;
}

.type-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 15px;
}

.type-button {
  background: white;
  border: 2px solid #e9ecef;
  border-radius: 12px;
  padding: 20px 15px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-height: 120px;
  position: relative;
  overflow: hidden;
}

.type-button:hover {
  border-color: #3a86ff;
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(58, 134, 255, 0.2);
}

.type-button.active {
  border-color: #3a86ff;
  background: linear-gradient(135deg, rgba(58, 134, 255, 0.1), rgba(131, 56, 236, 0.1));
  box-shadow: 0 4px 20px rgba(58, 134, 255, 0.3);
}

.type-button.active::before {
  content: '✓';
  position: absolute;
  top: 8px;
  right: 8px;
  background: #3a86ff;
  color: white;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
}

.type-icon {
  font-size: 2rem;
  margin-bottom: 5px;
}

.type-label {
  font-weight: 600;
  color: #333;
  font-size: 1rem;
  margin-bottom: 5px;
}

.type-button.active .type-label {
  color: #3a86ff;
}

.type-desc {
  font-size: 0.85rem;
  color: #666;
  line-height: 1.3;
}

.type-button.active .type-desc {
  color: #555;
}

.status-badge {
  position: absolute;
  top: 5px;
  left: 5px;
  background: #ffc107;
  color: #856404;
  padding: 2px 6px;
  border-radius: 8px;
  font-size: 0.7rem;
  font-weight: 500;
}

.status-badge.coming {
  background: #6c757d;
  color: white;
}

.type-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

.type-button:disabled:hover {
  border-color: #e9ecef;
  box-shadow: none;
}

.type-button.beta {
  border-color: #ffc107;
}

.type-button.beta:hover {
  border-color: #ffc107;
  box-shadow: 0 4px 15px rgba(255, 193, 7, 0.2);
}
</style>